<div id="bookings" class="fright">
	<h2>Bookings</h2>
<% is_admin = (Member.find(session[:member_id]).role == 'admin') %>
    <% if session[:member_id] and (session[:member_id] == @member.id or is_admin) %>

    <% if is_admin %>
        <h3>For the past 3 months</h3>
        <ul>
        <% @member.reservations.each do |reservation| %>
        <li><%= view_reservation(reservation)%> <%= reservation.start_date.strftime('%a, %d %b %Y') %></li>
        <% end %>
        </ul>
    <% end %>

    <h3><%= Time.now.beginning_of_week.strftime('%a, %d %b %Y') %> to <%= Time.now.advance(:weeks => 1).beginning_of_week.strftime('%a, %d %b %Y') %></h3>
    <ul class="bookingtotals">
    <% @categories.each do |cat| %>
      <% sum = 0 %>
      <% @w_reservations.each do |res| %>
        <% (sum += (res.user_end_date - res.start_date)) if res.post.category_id == cat.id %>
      <% end %>
      <li>Total of <%= (sum / 3600).floor %> hours <%= (((sum / 3600) - (sum / 3600).floor) * 60).ceil %> minutes for <%= cat.title %></li>
    <% end %>
    </ul>
    <% end %>
<ul>
    <% start_date = 1.days.ago %>
    <% @member.reservations.each do |res| %>
    <% title = res.start_date.strftime('%a, %d %b %Y') %>
    <% if start_date != nil and title != start_date.strftime('%a, %d %b %Y') -%>
        <h4><%= title %></h4>
        <% start_date = res.start_date -%>
    <% end -%>
    <li><%= view_reservation(res) %></li>
<% end %>
</ul>
</div><!-- end of bookings -->


<h2>
<% url = url_for_file_column('member', 'image', 'thumb') -%>
<%= image_tag(url) if url %>
<%= @member.login %>
</h2>

<% if session[:member_id] and session[:member_id] == @member.id %>
<p class="points"><span<% puts ' class="low"' if @member.credit < 10 %>><%= @member.credit %></span> points</p>
<% end %>

<ul>
<% if @member.blog%>
	<li><a href="<%= @member.blog %>">Website</a><br/>
<% end %>
<% if @member.role == 'member' or @member.role == 'admin'%>    
<% if @member.linkedin and @member.linkedin.size > 0 %>
	<li><a href="<%= @member.linkedin %>">LinkedIn</a><br/>
<% end %>
<% if @member.facebook and @member.facebook.size > 0 %>
	<li><a href="<%= @member.facebook %>">Facebook</a><br/> 
<% end %>
<% if @member.twitter and @member.twitter.size > 0 %>
	<li><a href="http://twitter.com/<%= @member.twitter %>">Twitter</a><br/> 
<% end %>
<% if @member.flickr and @member.flickr.size > 0 %>
    <a href="<%= @member.flickr %>">Flickr</a>
<% end %>
<% if @member.biography and @member.biography.size > 0 %><h3>About me</h3>
<%= simple_format(@member.biography)%>
<% end %>
<% end %>
</p>